<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css"
	rel="stylesheet">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>Insert title here</title>
</head>
<script type="text/javascript">
$(function(){
	$("#tab").datagrid({
		url:'Order_showOrder',
		rownumbers:true,
		columns:[[    
		          {field:'checkbox',checkbox:true},
		          {field:'oid',title:'订单编号',width:80},    
		          {field:'startp',title:'出发地',width:80}, 
		          {field:'endp',title:'目的地',width:80},  
		          {field:'ostate',title:'订单状态',width:80},    
		          {field:'otype',title:'订单类别',width:80}, 
		          {field:'logstate',title:'物流状态',width:80}, 
		          {field:'osenddate',title:'寄件日期',width:80}, 
		          {field:'osendman',title:'寄件人',width:80},    
		          {field:'sgetman',title:'收件人',width:80}, 
		          {field:'osendtel',title:'寄件人联系方式',width:100},    
		          {field:'ogettel',title:'收件人联系方式',width:100}, 
		          {field:'paystate',title:'支付状态',width:80},    
		          {field:'paystyle',title:'支付方式',width:80}, 
		          {field:'gtname',title:'货物类别',width:80},  
		          {field:'goodsweight',title:'货物重量',width:80},    
		          {field:'goodsvolume',title:'货物体积',width:80}, 
		          {field:'goodsname',title:'货物名',width:80},    
		          {field:'goodsnumber',title:'货物数量',width:80}, 
		          {field:'valuation',title:'保价金额',width:80},    
		          //{field:'insprice',title:'保价资费',width:80},    
		         // {field:'sumprice',title:'总费用',width:120},
		      ]],
		     pagination:true,
			 pagePosition:'bottom',
		     pageSize:10,
		     pageList:[10,5,15,20],
		   toolbar: [{
			iconCls: 'icon-add',
			text:'客户下订单',
			handler: function(){
				$('#showOrder').window('open'); 
				//分别清除框中各项的值
				//$('#oid').textbox('clear',true);
			//	$('#ostartp').combobox('clear',true);
				///$("#osenddata").datetimebox('clear',true);
				//$('#osendm').textbox('clear',true);
				//$('#osendtel').numberbox('clear',true);
		
				
			}
		}]   
	})

	$('#btnsure').bind('click', function(){    
		 var oid=$("#oid").val();
		 var ostartp=$("#ostartp").combobox('getValue');//出发地
		 var osenddata=$("#osenddata").datetimebox('getValue');//寄件日期
		 var osendm=$("#osendm").val();//寄件人
		 var osendtel=$("#osendtel").val();//联系方式
	     var oendp=$("#oendp").combobox('getValue');//目的地
	     var ogetm=$("#ogetm").val();//收件人
		 var ogettel=$("#ogettel").val();//联系方式
		 var ostate=$("#ostate").combobox('getValue');//订单状态
		 var otype=$("#otype").combobox('getValue');//订单类别
		 var logstate=$("#logstate").combobox('getValue');//物流状态 
		 var gtname=$("#gtname").combobox('getValue');
		 var goodsweight=$("#goodsweight").numberbox('getValue');//获取重量
		
		 var goodsvolume=$("#goodsvolume").numberbox('getValue');
		 var goodsname=$("#goodsname").val();
		 var goodsnumber=$("#goodsnumber").numberbox('getValue');
		 var paystate=$("#paystate").combobox('getText');//支付状态
		 var paystyle=$("#paystyle").combobox('getText');
		 var valuation=$("#valuation").numberbox('getValue');
		 
	    	 $.ajax({
	        	 url:'Order_insertOrder',
	        	 traditional:true,
	        	 type:'post',
	        	 data:{'corder.startp':ostartp,'corder.osenddate':osenddata,'corder.osendman':osendm,'corder.osendtel':osendtel,'corder.endp':oendp,
	        'corder.sgetman':ogetm,'corder.ogettel':ogettel,'ostate.ostate':ostate,'otype.otype':otype,'logstate.logstate':logstate,'goodstype.gtname':gtname,'corder.goodsweight':goodsweight,
	        'corder.goodsvolume':goodsvolume,'corder.goodsname':goodsname,'corder.goodsnumber':goodsnumber,'corder.paystate':paystate,'corder.paystyle':paystyle,'corder.valuation':valuation},
	      	 	 dataType:'text',
	      		 success:function(insert){
	      			 
	      			 if(insert=="1"){
	      				$.messager.alert('提示','恭喜下单成功！','info');	
	      				$('#tab').datagrid('reload');
	      			 }else{
	      				$.messager.alert('提示','下单失败，请重新填写！','info');
	      			 }
	      			 
	          }
	        	 
		 })
		 $('#tab').datagrid('reload'); 
 		 $('#showOrder').window("close");	
    });
	
	$('#btncancel').bind('click', function(){ 
		$('#showOrder').window('close');
	})
	
	//下拉菜单，出发地
	$('#ostartp').combobox({    
	    url:'Option_option',    
	    valueField:'startp',    
	    textField:'startp',
	    lines:true,
	    panelHeight:'auto',
	    editable:false,
	}); 
	//目的地
	$('#oendp').combobox({    
	    url:'Option_option',    
	    valueField:'startp',    
	    textField:'startp',
	    lines:true,
	    panelHeight:'auto',
	    editable:false,
	}); 
	//订单状态
	$('#ostate').combobox({    
	    url:'Option_ostate',    
	    valueField:'text',    
	    textField:'text',
	    lines:true,
	    panelHeight:'auto',
	    editable:false,
	    disabled:true
	});
	$('#ostate').combobox('setValue','未处理')
	//订单类别
	$('#otype').combobox({    
	    url:'Option_otype',    
	    valueField:'text',    
	    textField:'text',
	    lines:true,
	    panelHeight:'auto',
	    editable:false,
	});
	//物流状态
	$('#logstate').combobox({    
	    url:'Option_logstate',    
	    valueField:'text',    
	    textField:'text',
	    lines:true,
	    panelHeight:'auto',
	    editable:false,
	    disabled:true
	});
	$('#logstate').combobox('setValue','待发货')
	//获取物品类别
	$('#gtname').combobox({    
	    url:'Option_goodstype',    
	    valueField:'text',    
	    textField:'text',
	    lines:true,
	    panelHeight:'auto',
	    editable:false,
	});
	//支付状态
	$('#paystate').combobox({    
	    lines:true,
	    panelHeight:'auto',
	    editable:false,
	    disabled:true
	});
	//支付方式
	$('#paystyle').combobox({    
		    lines:true,
		    panelHeight:'auto',
		    editable:false,
		});
	
})
</script>

<body>
<table id="tab"></table>
<div id="showOrder" class="easyui-window" data-options="closed:true,title:'下订单',collapsible:false,minimizable:false,closable:true,modal:true" style="width:1000px;height:300px">
<div>
<input id="oid" name="oid" type="text"    
  style="display:none" /> <br/>
  <span>出发地:</span>
<input id="ostartp" name="corder.startp" type="text" class="easyui-combobox"     
    required="required" />&nbsp;
    <span>寄件日期:</span>
<input id="osenddata" name="corder.osenddate" type="text" class="easyui-datetimebox"     
    required="required" />&nbsp;
    <span>寄件人:</span>
<input id="osendm" name="corder.osendman" type="text" class="easyui-validatebox"     
    required="required"   />&nbsp;
    <span>联系方式:</span>
<input id="osendtel" name="corder.osendtel" type="text" class="easyui-validatebox"     
    required="required"  />&nbsp;<br/><br/>
    
    <span>目的地:</span>
<input id="oendp" name="corder.endp" type="text" class="easyui-combobox"     
    required="required"  />&nbsp;
    <span>收件人:</span>
<input id="ogetm" name="corder.sgetman" type="text" class="easyui-validatebox"     
    required="required"  />&nbsp;
    <span>联系方式:</span>
<input id="ogettel" name="corder.ogettel" type="text" class="easyui-validatebox"     
    required="required"  />&nbsp;<br/><br/>
    
    <span>订单状态:</span>
<input id="ostate" name="ostate.ostate" type="text" class="easyui-combobox"     
    required="required" />&nbsp;
    <span>订单类别:</span>
<input id="otype" name="otype.otype" type="text" class="easyui-combobox"     
    required="required"  />&nbsp;
    <span>物流状态:</span>
<input id="logstate" name="logstate.logstate" type="text" class="easyui-combobox"     
    required="required" />&nbsp;<br/><br/>
    
    
    <span>物品类别:</span>
<input id="gtname" name="goodstype.gtname" type="text" class="easyui-combobox"     
    required="required"  style="width:110px"/>&nbsp;
    <span>货物重量(kg):</span>
<input id="goodsweight" name="corder.goodsweight" type="text" class="easyui-numberbox"     
    required="required"  style="width:80px" />&nbsp;
    <span>货物体积(m3):</span>
<input id="goodsvolume" name="corder.goodsvolume" type="text" class="easyui-numberbox"     
    required="required"   style="width:80px"/>&nbsp;
    <span>货物名:</span>
<input id="goodsname" name="corder.goodsname" type="text" class="easyui-validatebox"     
       style="width:120px"/>&nbsp;
    <span>货物数量(件):</span>
<input id="goodsnumber" name="corder.goodsnumber" type="text" class="easyui-numberbox"     
    required="required"   style="width:80px"/>&nbsp;<br/><br/>
    
    <span>支付状态:</span>
<!--  <input id="paystate" name="paystate" type="text" class="easyui-combobox"     
    required="required" validType="" missingMessage="请输入" />&nbsp;-->
<select id="paystate" name="corder.paystate" style="width:135px" required="required"  >   
    <option value="text1">未支付</option>   
    <option value="text2">已支付</option>   
</select>&nbsp;
    <span>支付方式:</span>
 <select id="paystyle" name="corder.paystyle" style="width:135px" required="required" >   
    <option value="cash">现金</option>   
    <option value="qita">其他</option>   
</select>&nbsp;
    <span>保价金额(元):</span>
<input id="valuation" name="corder.valuation" type="text" class="easyui-numberbox"     
    required="required" />&nbsp;<br/><br/>
   <div style="margin-left:30px;" align="center"> 
   <a id="btnsure" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">确认下单</a>
    <a id="btncancel" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-no'">取消下单</a>
    </div>
  </div>
  
</div>



</body>
</html>